home *** CD-ROM | disk | FTP | other *** search
- #include "KillApp.h"
-
- /**********************************
-
- QuitApps
- DTS Code Snippet to quit all running applications (except yourself)
-
- note: to work properly, the calling application must have a standard
- event loop with menus (to support puppet string quits for apps that
- don't support core appleevents.
-
- note#2: remember to set the applevent aware flag in your app if you use
- this code
-
- written by Steven Falkenburg 9/4/91
-
- **********************************/
-
- /* quits an app of the given process id */
-
- OSErr QuitAnApp(ProcessSerialNumber *proc)
- {
- OSErr err;
- AEAddressDesc target;
- AppleEvent theAE,aeReply;
-
- theAE.dataHandle = aeReply.dataHandle = target.dataHandle = nil;
-
- err = AECreateDesc(typeProcessSerialNumber,(Ptr)proc,sizeof(ProcessSerialNumber),&target);
- if (err!=noErr)
- return err;
-
- err = AECreateAppleEvent(kCoreEventClass,kAEQuitApplication,&target,
- kAutoGenerateReturnID,kAnyTransactionID,&theAE);
- if (err!=noErr) {
- AEDisposeDesc(&target);
- return err;
- }
-
- err = AESend(&theAE,&aeReply,kAENoReply,kAENormalPriority,kNoTimeOut,nil,nil);
-
- AEDisposeDesc(&target);
- AEDisposeDesc(&theAE);
-
- return err;
- }
-